package com.guanyong.webapi.controllers.api;

import com.guanyong.model.SubjectModel;
import com.guanyong.services.SubjectService;
import com.guanyong.utils.Comm.ResultObject;
import com.guanyong.utils.NetUtils.UploadFileUtil;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by mxk on 2017/9/22.
 */
@RestController
@RequestMapping("/api/subject/")
public class SubjectApi {
    @Autowired
    SubjectService subjectService;

    @Autowired
    UploadFileUtil uploadFileUtil;

    @RequestMapping(value = "subjectalllist", method = RequestMethod.GET)
    ResultObject<List<SubjectModel>> getsubjectalllist(HttpServletRequest request ) {
        ResultObject<List<SubjectModel>> result = new ResultObject<List<SubjectModel>>();
        List<SubjectModel> list=subjectService.GetSubjectAllModel();
        result.setResult(list);
        return result;
    }

    @RequestMapping(value = "subjecttypelist", method = RequestMethod.GET)
    ResultObject<List<SubjectModel>> subjecttypelist(HttpServletRequest request,
                                                     @RequestParam Integer type) {
        ResultObject<List<SubjectModel>> result = new ResultObject<List<SubjectModel>>();
        List<SubjectModel> list=subjectService.GetSubjectByTypeModel(type);
        result.setResult(list);
        return result;
    }
}
